﻿'*******************************************************************
' Program: Data Center Visio Rack Tool
' Author: Albert E Edlund
' Date:
'
' Purpose:
'
'
'*******************************************************************


Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Imports Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging


Imports System
Imports System.ComponentModel
Imports System.Collections.Generic

' need this for prod enumerations
Imports visRackAppConnectivity.dc_Product



Public Class dc_Component
    Implements INotifyPropertyChanged

#Region " Events "

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

    Private Sub OnPropertyChanged(ByVal info As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    End Sub

#End Region

#Region " Enumerations "
   

    ' for data center move status
    Public Enum ecompMoveStatus
        cmUnknown = -1
        cmOutPlan = 0
        cmInPlan = 1
        cmMoved = 2
    End Enum

    ' these are the context commands
    ' for testing 
    Public Enum DC_RackCommand

        CreateDocument = 1
        OpenDocument = 2
        ShapeEventDrop = 3
        ShapeDoubleClick = 4
        BeginEventExcludeRange = 5
        EndEventExcludeRange = 6
        ' test icmp
        testIcmp = 10
        ' test snmp
        testSNMPData = 11
        ' test wmi
        testWkstData = 12
        ' call terminal services client
        testMSTSC = 14
        ' use telnet (used to hyperlink until vista/ie7)
        testTelnet = 13
        ' toggle shape text visible
        testTCOn = 15
        testTopology = 16
        ' page ping
        testPagePing = 17
        ' toggle for showing data link
        testPageLink = 18
        ' toggle for cable visible (allow cable visible to follow shape selected)
        testCableToggle = 20
        ' search for a component
        testCompSearch = 21
        ' add ssh support to the menu
        testSSH = 22

        ' add page sync support
        testPageSync = 23
        ' add a network link to the page
        testAddNetLink = 19
    End Enum


#End Region

#Region " Properties and definitions "

    Private m_compKey As Int32
    Public Const constCompKey As Int32 = -1
    Public Property compKey() As Int32
        Get
            Return Me.m_compKey
        End Get
        Set(ByVal value As Int32)
            Me.m_compKey = value
            Me.OnPropertyChanged("compKey")
        End Set
    End Property

    Private m_compLocKey As Int32
    Public Const constCompLocKey As Int32 = -1
    Public Property compLocKey() As Int32
        Get
            Return Me.m_compLocKey
        End Get
        Set(ByVal value As Int32)
            Me.m_compLocKey = value
            Me.OnPropertyChanged("compLocKey")
        End Set
    End Property

    Private m_compName As String
    Public Const constCompName As String = "CompName"
    Public Property compName() As String
        Get
            Return Me.m_compName
        End Get
        Set(ByVal value As String)
            Me.m_compName = value
            Me.OnPropertyChanged("compName")
        End Set
    End Property

    Private m_compLabel As String
    Public Const constCompLabel As String = "na"
    Public Property compLabel() As String
        Get
            Return Me.m_compLabel
        End Get
        Set(ByVal value As String)
            Me.m_compLabel = value
            Me.OnPropertyChanged("compLabel")
        End Set
    End Property

    Private m_compParentSlot As String
    Public Const constcompParentSlot As String = "na"
    Public Property compParentSlot() As String
        Get
            Return Me.m_compParentSlot
        End Get
        Set(ByVal value As String)
            Me.m_compParentSlot = value
            Me.OnPropertyChanged("compParentSlot")
        End Set
    End Property

    Private m_compComments As String
    Public Const constCompComments As String = "none"
    Public Property compComments() As String
        Get
            Return Me.m_compComments
        End Get
        Set(ByVal value As String)
            Me.m_compComments = value
            Me.OnPropertyChanged("compComments")
        End Set
    End Property

    ' parent key may be null...
    Private m_compParentKey As Int32
    Public Const constCompParentKey As Int32 = -1
    Public Property compParentKey() As Int32
        Get
            Return Me.m_compParentKey
        End Get
        Set(ByVal value As Int32)
            Me.m_compParentKey = value
            Me.OnPropertyChanged("compParentKey")
        End Set
    End Property


    Private m_compMoveStatus As ecompMoveStatus
    Public Const constCompMoveStatus As ecompMoveStatus = ecompMoveStatus.cmUnknown
    Public Property compMoveStatus() As ecompMoveStatus
        Get
            Return Me.m_compMoveStatus
        End Get
        Set(ByVal value As ecompMoveStatus)
            Me.m_compMoveStatus = value
            Me.OnPropertyChanged("compMoveStatus")
        End Set
    End Property

    Private m_compParentSubType As dc_Product.VnetSubtype
    Public Const constCompParentSubType As dc_Product.vnetSubtype = dc_Product.vnetSubtype.stUnknown
    Public Property compParentSubType() As dc_Product.VnetSubtype
        Get
            Return Me.m_compParentSubType
        End Get
        Set(ByVal value As dc_Product.VnetSubtype)
            If Not TypeDescriptor.GetConverter(GetType(dc_Product.VnetSubtype)).IsValid(value) Then
                ' Throw New ArgumentException()
                value = dc_Product.vnetSubtype.stUnknown
            End If
            Me.m_compParentSubType = value
            Me.OnPropertyChanged("compParentSubType")
        End Set
    End Property

    Private m_vNetType As dc_Product.VnetType
    Public Const constCompType As dc_Product.vnetType = dc_Product.vnetType.ptUnknown
    Public Property compType() As dc_Product.VnetType
        Get
            Return Me.m_vNetType
        End Get
        Set(ByVal value As dc_Product.VnetType)
            If Not TypeDescriptor.GetConverter(GetType(dc_Product.VnetType)).IsValid(value) Then
                'Throw New ArgumentException()
                value = dc_Product.vnetType.ptUnknown
            End If
            Me.m_vNetType = value
            Me.OnPropertyChanged("compType")
        End Set
    End Property

    Private m_vNetSubtype As dc_Product.VnetType
    Public Const constCompSubtype As dc_Product.vnetSubtype = dc_Product.vnetSubtype.stUnknown
    Public Property compSubtype() As dc_Product.VnetSubtype
        Get
            Return Me.m_vNetSubtype
        End Get
        Set(ByVal value As dc_Product.VnetSubtype)
            If Not TypeDescriptor.GetConverter(GetType(dc_Product.VnetSubtype)).IsValid(value) Then
                'Throw New ArgumentException()
                value = dc_Product.vnetSubtype.stUnknown
            End If
            Me.m_vNetSubtype = value
            Me.OnPropertyChanged("compSubType")
        End Set
    End Property

    Private m_compVendorKey As Int32
    Public Const constCompVendorKey As Int32 = -1
    Public Property compVendorKey() As Int32
        Get
            Return Me.m_compVendorKey
        End Get
        Set(ByVal value As Int32)
            Me.m_compVendorKey = value
            Me.OnPropertyChanged("compVendorKey")
        End Set
    End Property

    Private m_compLastUpdate As Date
    Public Const constCompLastUpdate As Date = #1/1/2001#
    Public Property compLastUpdate() As Date
        Get
            Return Me.m_compLastUpdate
        End Get
        Set(ByVal value As Date)
            Me.m_compLastUpdate = value
            Me.OnPropertyChanged("compLastUpdate")
        End Set
    End Property

    Private m_compLastEdit As String
    Public Const constCompLastEdit As String = "na"
    Public Property compLastEdit() As String
        Get
            Return Me.m_compLastEdit
        End Get
        Set(ByVal value As String)
            Me.m_compLastEdit = value
            Me.OnPropertyChanged("compLastEdit")
        End Set
    End Property

    Private m_compView As dc_Product.View
    Public Const constCompView As dc_Product.View = dc_Product.View.viewRear
    Public Property compView() As dc_Product.View
        Get
            Return Me.m_compView
        End Get
        Set(ByVal value As dc_Product.View)
            If Not TypeDescriptor.GetConverter(GetType(dc_Product.View)).IsValid(value) Then
                Throw New ArgumentException()
            End If
            Me.m_compView = value
            Me.OnPropertyChanged("compView")
        End Set
    End Property


    Private m_compParentVendor As Int32
    Public Const constCompParentVendor As Int32 = -1
    Public Property pCompParentVendor() As Int32
        Get
            Return Me.m_compParentVendor
        End Get
        Set(ByVal value As Int32)
            Me.m_compParentVendor = value
            Me.OnPropertyChanged("compParentVendor")
        End Set
    End Property


#End Region

#Region " Methods "


    Public Sub initProperties()

        compKey = constCompKey
        compLocKey = constCompLocKey
        compName = constCompName
        compLabel = constCompLabel
        compParentSlot = constcompParentSlot
        compComments = constCompComments
        compParentKey = constCompParentKey
        compMoveStatus = constCompMoveStatus
        compParentSubType = constCompParentSubType
        compType = constCompType
        compSubtype = constCompSubtype
        compVendorKey = constCompVendorKey
        compLastUpdate = Now
        compLastEdit = constCompLastEdit

        compView = constCompView
        pCompParentVendor = constCompParentVendor


    End Sub


#End Region

#Region " Context Menu definitions "

    '
    ' currently only the shape double click is entered
    '



    ' these are used in the add right mouse click section
    Private Const ContextRightMouseAction As String = "solution=dc_rack "
    Private Const ContextBeginMarker As String = "/"
    Private Const ContextCommand As String = "cmd="
    Private Const DividerBarPrefix As String = "_"
    Private Const AddToBottomPrefix As String = "%"
    Private Const AcceleratorPrefix As String = "&"


    '
    ' context command defined in 
    '
    Public Const MenuPingCaption As String = "Test ICMP Connection"
    Public Const MenuPing As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" & _
        ContextBeginMarker & _
        ContextRightMouseAction & _
        ContextBeginMarker & _
        ContextCommand & "10"")"

    Public Const MenuSNMPCaption As String = "Test SNMP Data"
    Public Const MenuSNMP As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "11"")"

    Public Const MenuWMICaption As String = "Test WMI Data"
    Public Const MenuWMI As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "12"")"

    ' as of vista/ie7 cannot use hyperlink anymore
    Public Const MenuTelnetCaption As String = "Conn Telnet"
    Public Const MenuTelnet As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "13"")"

    Public Const MenuSSHCaption As String = "Conn SSH"
    Public Const MenuSSH As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "22"")"


    Public Const MenuMSTSCCaption As String = "Terminal Server"
    Public Const MenuMSTS As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "14"")"

    Public Const MenuTCOnCaption As String = "Toggle Text"
    Public Const MenuTCOn As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "15"")"

    Public Const MenuTopoCaption As String = "Show Topology"
    Public Const MenuTopoEvent As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "16"")"

    '
    ' use the same caption as for the shape ping, so no need to define
    '
    'Public Const MenuPingCaption As String = "Test ICMP Connection"
    '
    Public Const MenuPagePing As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "17"")"

    '
    ' when using datarecordsets allow selection of shape to automatically
    ' highlight a dr record
    '
    Public Const MenuLinkCaption As String = "Toggle Link To Data"
    Public Const MenuPageLink As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "18"")"

    Public Const MenuAddNetLinkCaption As String = "Add Network Link"
    Public Const MenuAddNetLink As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "19"")"


    Public Const MenuCableToggleCaption As String = "Toggle Cable Visible"
    Public Const MenuCableToggle As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "20"")"


    Public Const MenuCompSearchCaption As String = "Component Search"
    Public Const MenuCompSearch As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "21"")"


    ' Menu caption with an accelerator key assignment (&)
    Public Const MenuPageSyncCaption As String = "PageSync"
    Public Const MenuPageSync As String = _
        "RUNADDONWARGS(""QueueMarkerEvent"",""" + _
        ContextBeginMarker + _
        ContextRightMouseAction + _
        ContextBeginMarker + _
        ContextCommand + "23"")"


    '
    ' the structure needed for the action menu parameters
    '
    Public Structure stcMenuArray
        Public Command As Integer
        Public Enabled As Boolean
        Public Checked As Boolean
        Public Group As Boolean
        Public ToBottom As Boolean
    End Structure


#End Region

#Region " Constructor "

    Public Sub New()
        initProperties()
    End Sub

    Public Sub New(ByVal strUserId As String)
        initProperties()
        Me.m_compLastEdit = strUserId
    End Sub

#End Region

End Class






